import 'package:ccshop/entites/MenuEntity.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class HomeMenuGridView extends StatelessWidget {
  List<MenuEntity> imgNames;

  HomeMenuGridView() {
    imgNames = List();
    MenuEntity entity = MenuEntity("images/shop_sc.png", "蔬菜");
    imgNames.add(entity);

    entity = MenuEntity("images/shop_rqd.png", "肉禽蛋");
    imgNames.add(entity);

    entity = MenuEntity("images/shop_hxsc.png", "海鲜水产");
    imgNames.add(entity);

    entity = MenuEntity("images/shop_sslc.png", "熟食凉菜");
    imgNames.add(entity);

    entity = MenuEntity("images/shop_sdsp.png", "速冻食品");
    imgNames.add(entity);

    entity = MenuEntity("images/shop_xxsg.png", "新鲜水果");
    imgNames.add(entity);

    entity = MenuEntity("images/shop_mmly.png", "米面粮油");
    imgNames.add(entity);

    entity = MenuEntity("images/shop_tc.png", "特产");
    imgNames.add(entity);

    entity = MenuEntity("images/shop_jsyp.png", "酒水饮品");
    imgNames.add(entity);

    entity = MenuEntity("images/shop_mfbh.png", "美肤百货");
    imgNames.add(entity);
  }

  @override
  Widget build(BuildContext context) {
    return GridView.builder(
        itemCount: imgNames.length,
        physics: NeverScrollableScrollPhysics(),
        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
          crossAxisCount: 5,
        ),
        itemBuilder: (context, index) {
          return Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Image.asset(
                imgNames[index].menuSrc,
                width: 30,
                height: 30,
              ),
              Padding(
                padding: EdgeInsets.only(top: 4),
              ),
              Text(
                imgNames[index].menuName,
                style: TextStyle(
                  fontSize: 12,
                ),
              )
            ],
          );
        });
  }
}
